package com.taotao.thread.Test1;

import java.util.concurrent.TimeUnit;

/**
 * @author wangjin
 * @title: T01_ReentrantLock1
 * @projectName thread
 * @description: 可重入锁
 * @date 2022/5/4 0004 9:03
 */
public class T01_ReentrantLock1 {
    synchronized void m(){
        for (int i = 0; i <10 ; i++) {
            try {
                TimeUnit.MICROSECONDS.sleep(10);
            }catch (Exception e){
                e.getMessage();
            }
            System.out.println(i);
            if(i/2==0){
                m2();
            }
        }
    }

    private synchronized  void m2() {
        System.out.println("m2 ....");
    }


    public static void main(String[] args) {
        T01_ReentrantLock1 reentrantLock1 = new T01_ReentrantLock1();
        new Thread(reentrantLock1::m).start();
        try {
            TimeUnit.MICROSECONDS.sleep(10);
        }catch (Exception e){
            e.getMessage();
        }
    }

}
